package org.jfree.chart.demo;
import java.io.IOException;

import net.tinyos.packet.BuildSource;
import net.tinyos.packet.PacketSource;
import net.tinyos.util.Dump;
import net.tinyos.util.PrintStreamMessenger;


public class Main {

	/**
	 * @param args
	 */
	static int i= 1;
	static String  source = "network@10.5.5.5:10002";
	static PacketSource reader =  BuildSource.makePacketSource(source);
	public static Double message () {

			reader = BuildSource.makePacketSource(source);
		try {
			reader.open(PrintStreamMessenger.err);
			System.err.println("Group\tCounter\tLight");

				final byte[] packet = reader.readPacket();
				try {
					SensorListenMsg msg = new SensorListenMsg(packet);
					System.out.println(msg.getGroup() + "\t" + msg.getCounter()
							+ "\t Sensor Reading : " + msg.getLight());
					Long s = msg.getLight();
					reader.close();
					return s.doubleValue();
				} catch (Exception ex) {
						ex.printStackTrace();
				}
				// System.out.println();
				System.out.flush();
		} catch (IOException e) {
			System.err.println("Error on " + reader.getName() + ": " + e);
		}
		return 1.1;
	}
}
